// Fill out your copyright notice in the Description page of Project Settings.


#include "SGSaveGame.h"
#include "Kismet/GameplayStatics.h"

USGSaveGame::USGSaveGame()
{
	

}

void USGSaveGame::SaveGame(FString str)
{
	USGSaveGame* SaveGameInstance = Cast<USGSaveGame>(UGameplayStatics::CreateSaveGameObject(USGSaveGame::StaticClass()));
	SaveGameInstance->PlayerName = str;

	UGameplayStatics::SaveGameToSlot(SaveGameInstance, TEXT("SaveSlot"), 0);

	UE_LOG(LogTemp, Warning, TEXT("Save Game...."));

	//return UGameplayStatics::SaveGameToSlot(SaveGameIns, TEXT("SaveGame"), 0);
}

void USGSaveGame::LoadGame()
{
	USGSaveGame* SaveGameInstance = Cast<USGSaveGame>(UGameplayStatics::CreateSaveGameObject(USGSaveGame::StaticClass()));
	SaveGameInstance = Cast<USGSaveGame>(UGameplayStatics::LoadGameFromSlot(TEXT("SaveSlot"), 0));
	if (SaveGameInstance) {
		FString teststr = SaveGameInstance->PlayerName;
		UE_LOG(LogTemp, Warning, TEXT("%s"), *teststr);

		//return true;
	}
	/*else {
		return false;
	}*/

}
